<template>
  <div>
    <el-dialog title="发送指令" :visible.sync="visible">
      <el-form :model="commentDto">
        <el-form-item label="设备Key" :label-width="formLabelWidth">
          <el-input v-model="commentDto.deviceKey" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="继电器编号" :label-width="formLabelWidth">
          <el-input v-model="commentDto.deviceSubCode" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="指令名称" :label-width="formLabelWidth">
          <el-input v-model="commentDto.cmdName" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="指令值" :label-width="formLabelWidth">
          <el-input v-model="commentDto.value" autocomplete="off"></el-input>
        </el-form-item>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="visible = false">取 消</el-button>
        <el-button type="primary" @click="fnControl">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "DeviceControl",
  props:{

  },
  data() {
    return {
      visible: false,
      commentDto: {
        deviceKey: '',
        deviceSubCode:'',
        cmdName:'',
        value:""
      },
      formLabelWidth: '120px'
    }
  }
  ,
  methods: {
    fnControl() {
      this.axios.post("http://localhost:8080/cmd/", this.commentDto).then(resp => {
        if (resp.data.code === "200") {
          this.$message.success("F发送指令成功");
          this.visible = false;
          this.$emit('closed');
        } else {
          this.visible = false;
          this.$message.error(resp.data.desc);
        }

      })
    }
  },
}
</script>

<style scoped>

</style>
